<?php
namespace sim\db\Entity;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * @Entity
 * @Table(name="user")
 */
class User extends MappedSuperclassBase
{

    /**
     *
     * @var integer
     * @Column(type="integer", nullable= true)
     * @ManyToOne(targetEntity="User", inversedBy="children")
     * @JoinColumn(name="parent_id", referencedColumnName="id")
     */
    protected $parent;

    /**
     *
     * @var integer
     * @Column(type="integer")
     */
    protected $group;

    /**
     *
     * @var integer
     * @Column(type="string")
     */
    protected $name;

    /**
     *
     * @var integer
     * @Column(type="string", name="full_name")
     */
    protected $fullName;

    /**
     *
     * @var integer
     * @Column(type="string")
     */
    protected $password;

    /**
     *
     * @var integer
     * @Column(type="string")
     */
    protected $email;

    /**
     *
     * @var datetime
     * @Column(type="datetime", name="date_create")
     */
    protected $dateCreate;

    /**
     *
     * @var datetime
     * @Column(type="datetime", name="date_update")
     */
    protected $dateUpdate;

    /**
     *
     * @var datetime
     * @Column(type="datetime", name="last_visit")
     */
    protected $lastVisit;

    /**
     *
     * @var integer
     * @Column(type="decimal", precision=10, scale=2) 
     */
    protected $balance;

    /**
     *
     * @var ArrayCollection
     * @OneToMany(targetEntity="User", mappedBy="parent")
     * 
     */
    protected $children;
    
    /**
     * @var ArrayCollection
     * @OneToMany(targetEntity="SimOwner", mappedBy="user")
     */
    protected $sims;
    
    /**
     *
     * @var ArrayCollection
     * @OneToMany(targetEntity="SimOwner", mappedBy="user")
     */
    protected $balances;

    function __construct()
    {
        $this->children = new ArrayCollection;
        $this->sims = new ArrayCollection;
    }

    public function getParent()
    {
        return $this->parent;
    }

    public function setParent(User $parent)
    {
        $this->parent = $parent;
        return $this;
    }

    public function getGroup()
    {
        return $this->group;
    }

    public function setGroup($group)
    {
        $this->group = $group;
    }

    public function getName()
    {
        return $this->name;
    }

    public function setName($name)
    {
        $this->name = $name;
    }

    public function getFullName()
    {
        return $this->fullName;
    }

    public function setFullName($fullName)
    {
        $this->fullName = $fullName;
    }

    public function getPassword()
    {
        return $this->password;
    }

    public function setPassword($password)
    {
        $this->password = $password;
    }

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }

    public function getDateCreate()
    {
        return $this->dateCreate;
    }

    public function setDateCreate($dateCreate)
    {
        $this->dateCreate = $dateCreate;
    }

    public function getDateUpdate()
    {
        return $this->dateUpdate;
    }

    public function setDateUpdate($dateUpdate)
    {
        $this->dateUpdate = $dateUpdate;
    }

    public function getLastVisit()
    {
        return $this->lastVisit;
    }

    public function setLastVisit($lastVisit)
    {
        $this->lastVisit = $lastVisit;
    }

    public function getBalance()
    {
        return $this->balance;
    }

    public function setBalance($balance)
    {
        $this->balance = $balance;
    }

    /**
     * 
     * @return ArrayCollection
     */
    public function getChildren()
    {
        return $this->children;
    }

    public function setChildren(ArrayCollection $children)
    {
        $this->children = $children;
    }

    public function addChildren(User $user)
    {
        $this->children->add($user);
        $user->setParent($this);
    }
    
    public function getSims()
    {
        return $this->sims;
    }

    public function setSims(ArrayCollection $sims)
    {
        $this->sims = $sims;
    }
    
    public function addSim(SimOwner $sim)
    {
        $this->sims->add($sim);
        $sim->setUser($this);
    }



}